package com.fieldchain.ex.fa100.ui.money.activity;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.fieldchain.ex.fa100.R;
import com.fieldchain.ex.fa100.access.Constant;
import com.fieldchain.ex.fa100.base.MyBaseActivity;
import com.fieldchain.ex.fa100.bean.CoinChoseBean;
import com.fieldchain.ex.fa100.ui.money.adapter.CoinChoseAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.fieldchain.ex.fa100.utils.net.access.HttpRequest;
import com.fieldchain.ex.fa100.utils.net.modle.ListRequest;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/10/17
 */
public class RecChoseActivity extends MyBaseActivity {
    private RelativeLayout reaBack;
    private TextView tvCenter;
    private RecyclerView rv;

    private CoinChoseAdapter adapter;
    private ArrayList<CoinChoseBean>list=new ArrayList<>();
    private int type;

    @Override
    public void findView() {
        reaBack = findViewById(R.id.rea_back);
        tvCenter = findViewById(R.id.tv_center);
        rv = findViewById(R.id.rv);
    }

    @Override
    public void setValue() {
        type=getIntent().getIntExtra("type",1);
        tvCenter.setText("充值币种");
        reaBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        adapter=new CoinChoseAdapter(mContext);
        rv.setLayoutManager(new GridLayoutManager(mContext,4));
        rv.setAdapter(adapter);
        getData();
    }

    @Override
    public int getLayout() {
        return R.layout.activity_rechargechose;
    }

    public void getData(){
        HashMap map=new HashMap();
        map.put("type",type+"");
        HttpRequest.getInstance().getRequest(map, Constant.recCoinList,new ListRequest<CoinChoseBean>() {
            @Override
            public void onSucess(List<CoinChoseBean> list, int code, String msg) {
                adapter.setData(list);
            }

            @Override
            public void onFaild(Exception e) {

            }
        });


    }
}
